package org.example.jiaxiao.controller;

import org.example.jiaxiao.entity.Exam;
import org.example.jiaxiao.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/exams")
public class ExamController {

    @Autowired
    private ExamService examService;

    //根据学生ID查询考试信息
    @GetMapping("/getStudentExams")
    public ResponseEntity<List<Exam>> getAllExams(@RequestParam("studentId") Integer studentId) {
        List<Exam> exams = examService.getAllExams(studentId);
        return ResponseEntity.ok(exams);
    }
}